using HKB.Common;
using HKB.Data.Dal;
using HKB.Data.Model;
using System;
using System.Collections.Generic;
using System.Data;
namespace HKB.Data.Bll
{
	public class ClientAnnal
	{
		private readonly HKB.Data.Dal.ClientAnnal dal = new HKB.Data.Dal.ClientAnnal();
		public int GetMaxId()
		{
			return this.dal.GetMaxId();
		}
		public bool Exists(int ClientAnnalID)
		{
			return this.dal.Exists(ClientAnnalID);
		}
		public int Add(HKB.Data.Model.ClientAnnal model)
		{
			return this.dal.Add(model);
		}
		public bool Update(HKB.Data.Model.ClientAnnal model)
		{
			return this.dal.Update(model);
		}
		public bool Delete(int ClientAnnalID)
		{
			return this.dal.Delete(ClientAnnalID);
		}
		public bool DeleteList(string ClientAnnalIDlist)
		{
			return this.dal.DeleteList(ClientAnnalIDlist);
		}
		public HKB.Data.Model.ClientAnnal GetModel(int ClientAnnalID)
		{
			return this.dal.GetModel(ClientAnnalID);
		}
		public HKB.Data.Model.ClientAnnal GetModelByCache(int ClientAnnalID)
		{
			string cacheKey = "ClientAnnalModel-" + ClientAnnalID;
			object obj = DataCache.GetCache(cacheKey);
			if (obj == null)
			{
				try
				{
					obj = this.dal.GetModel(ClientAnnalID);
					if (obj != null)
					{
						int configInt = ConfigHelper.GetConfigInt("ModelCache");
						DataCache.SetCache(cacheKey, obj, System.DateTime.Now.AddMinutes((double)configInt), System.TimeSpan.Zero);
					}
				}
				catch
				{
				}
			}
			return (HKB.Data.Model.ClientAnnal)obj;
		}
		public DataSet GetList(string strWhere)
		{
			return this.dal.GetList(strWhere);
		}
		public DataSet GetList(int Top, string strWhere, string filedOrder)
		{
			return this.dal.GetList(Top, strWhere, filedOrder);
		}
		public System.Collections.Generic.List<HKB.Data.Model.ClientAnnal> GetModelList(string strWhere)
		{
			DataSet list = this.dal.GetList(strWhere);
			return this.DataTableToList(list.Tables[0]);
		}
		public System.Collections.Generic.List<HKB.Data.Model.ClientAnnal> DataTableToList(DataTable dt)
		{
			System.Collections.Generic.List<HKB.Data.Model.ClientAnnal> list = new System.Collections.Generic.List<HKB.Data.Model.ClientAnnal>();
			int count = dt.Rows.Count;
			if (count > 0)
			{
				for (int i = 0; i < count; i++)
				{
					HKB.Data.Model.ClientAnnal clientAnnal = this.dal.DataRowToModel(dt.Rows[i]);
					if (clientAnnal != null)
					{
						list.Add(clientAnnal);
					}
				}
			}
			return list;
		}
		public DataSet GetAllList()
		{
			return this.GetList("");
		}
		public int GetRecordCount(string strWhere)
		{
			return this.dal.GetRecordCount(strWhere);
		}
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
		}
		public HKB.Data.Model.ClientAnnal GetAnnalItem(string whereStr)
		{
			return this.dal.GetAnnalItem(whereStr);
		}
		public HKB.Data.Model.ClientAnnal GetClientAnnalByClientID(int ClientID)
		{
			return this.dal.GetClientAnnalByClientID(ClientID);
		}
	}
}
